package interview.cases;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 *  锐锢面试总结
 *
 * */

public class Case1 {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                 while (true){
                   if(Thread.currentThread().isInterrupted()){
                       System.out.println("isInterrupted.....");
                       break;
                   }
                   try {
                         Thread.sleep(2000);
                   } catch (InterruptedException e) {
                         e.printStackTrace();
                   }
                    Thread.currentThread().interrupt();
                 }
            }
        });
        thread.start();
       // thread.start();
    }

    @Test
    public void testSelfIncresement(){
        int i=0,j=0;
        test1(i++);
        test1(++j);

    }


    public static void test1(int k){
        System.out.println("~~~~~~"+k+"~~~~~~~");
        System.out.println(k++);
        System.out.println("@"+k+"@");
        System.out.println(++k);
    }

    @Test
    public void testStr(){
        String str1 = "str1";
        String str2 = "str2";
        String str3 = "str3";
        System.out.println(str1.concat(str3));
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
        str1= str1.concat(str3);
        System.out.println(str1);
    }

    @Test
    public void CollectionTest() {
        List<Integer> list1 = new ArrayList<>();
        list1.add(1);
        list1.add(3);
        list1.add(1, 2);
        System.out.println(list1);
        List<Integer> list2 = new ArrayList<>(list1);
        list2.add(1);
        list2.add(3);
        System.out.println(list2);
        list2.set(0, 5);
        System.out.println(list2);
    }
}


